package com.render.gui;
import java.awt.Color;
import java.awt.Graphics2D;

import base.render.gui.Gui;


public class GuiStreak extends Gui
{
	private float speed;
	private int length;
	private int width;
	
	private Color color;
	
	private boolean isDead;
	
	public GuiStreak(int par1, int par2, float par3)
	{
		super(par1, par2, par3);
		this.speed = this.rand.nextFloat()*4F + 1F;
		this.length = this.rand.nextInt(176) + 64;
		this.width = this.rand.nextInt(15) + 1;
		this.color = this.getRandomColor();
		
		this.isDead = false;
	}
	
	public void onTickUpdate()
	{
		super.onTickUpdate();
		if (this.x - this.length > getWindowWidth())
		{
			this.setDead();
		}
	}
	
	public void onUpdate()
	{
		this.x += this.speed;
	}
	
	public void onPreRender(Graphics2D par1Graphics)
	{
		super.onPreRender(par1Graphics);
		par1Graphics.setColor(this.color);
		par1Graphics.fillRect(this.x - this.length / 2, this.y, this.length, this.width);
	}
	
	private Color getRandomColor()
	{
		Color color = Gui.getRandomColor(this.rand);
		while(color == Color.BLACK || color == Color.GRAY)
		{
			color = Gui.getRandomColor(this.rand);
		}
		return color;
	}
	
	public void setDead()
	{
		this.isDead = true;
	}
	
	public boolean isDead()
	{
		return this.isDead;
	}
}